<table id="tag_grid" class='f_s_10'>
</table>
<div id="tag_grid_pager">
</div>
<script type="text/javascript" charset="utf-8">
	$grid = $("#tag_grid").jqGrid({
		colModel:[{
			name:"name",
			label:"Ключевое слово",
			width:200
		},{
			name:"name",
			label:"Автор",
			width:250
		}],
		multiselect:true,
		url:"tag/grid",
		pager:"tag_grid_pager",
		sortname: 'id',
		rowNum:10,
		rowList:[10,20,30],
		viewrecords: true,
		caption:"Ключевые слова",
		width:520
	}).jqGrid('navGrid','#tag_grid_pager', {
		search:false,
		edit:false,
		add:false,
		del:false
	}).navButtonAdd('#tag_grid_pager', {
		title:"Создать новое ключевое слово",
		caption:"",
		buttonicon:"ui-icon-plus",
		onClickButton: function() {
			$.post('tag/new_',{form:true},function(d){
				if(d.html){
					var dia = $.dia({title:d.title,modal:true,width:'auto',height:'auto'});
					dia.html(d.html).dialog('open').bind('dialogclose',function(){
						$grid.trigger('reloadGrid');
					});
					initButton(dia);
				}
			},'json');
		},
		position:"last"
	}).navButtonAdd('#tag_grid_pager', {
		title:"Удаление ключевых слов",
		caption:"",
		buttonicon:"ui-icon-trash",
		onClickButton: function() {
			var ids = $grid.getGridParam('selarrrow').join(',');
			$.jConfirm("Вы точно хотите удалить, выбранные ключевые слова?",function(r){
				if(r){
					$.post('tag/delete',{id:ids},function(d){
						$grid.trigger('reloadGrid');
					},'json');
				}
			});
		},
		position:"last"
	});
</script>